Arch - Pacman

TOC

text goes here section_title

Pacman

A table of useful commands

Command Effect
pacman -Syuw download only, do NOT install packages
pacman -Sw Download specified package(s) as .tar.xz ball
pacman -F Search for package containing file
yay -Rns $(pacman -Qtdq) Remove orphans, their configuration(s) and unneeded dependencies
pacman -Qi | grep “Required By” List owning package of a dependent package
expac -Q %M Find all modified files in etc ( alternative pacman -Qkk |& grep Modification | grep /etc )

for more examples see https://wiki.archlinux.org/title/Pacman/Rosetta

To backup all of your currently installed package

  • Backup package in official repository
    • pacman -Qqen > pkglist-${HOSTNAME}-repo.txt
  • Backup package in arch user repository (AUR)
    • pacman -Qqem > pkglist-${HOSTNAME}-aur.txt

To restore / re-install all of your package

  • For repository package
    • pacman -S --needed - < pkglist-${HOSTNAME}-repo.txt
  • For AUR package
    • yay -S --needed - < pkglist-${HOSTNAME}-aur.txt

yay

yay

Preinstall steps

  • install base-devel is needed for compiling
    • sudo pacman -S --needed base-devel;
  • adjust makepkg threads to be dynamic
    • sudo sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j\${nproc}\"/" /etc/makepkg.conf
  • fix makepkg options, disable debug packages
    • sudo sed -i 's/^OPTIONS=.*/OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug lto)/' /etc/makepkg.conf

Installing

cd /tmp
git clone https://aur.archlinux.org/yay-bin.git
cd yay-bin
makepkg -si --noconfirm
yay -Y --devel --answerclean a --answerdiff n --removemake --cleanafter  --save

If replacing another AUR helper

Use yay -Y --gendb to generate a development package database for *-git packages that were installed without yay. This command should only be run once.

Source: https://github.com/Jguer/yay

Local AUR Repo

  • sudo nano /etc/makepkg.conf
    • PKGDEST=/home/packages
  • sudo systemctl --full --force edit repo.path
    • [Path]
      PathChanged=/home/packages
      Unit=repo.service
      TriggerLimitIntervalSec=30sec
      
      [Install]
      WantedBy=multi-user.target
  • sudo systemctl --user --full --force edit repo.service
    • [Service]
      Type=oneshot
      ExecStartPre=/usr/bin/logger Start - Local AUR Repo Update
      ExecStart=/bin/sh -c '/usr/bin/repo-add --nocolor --quiet --remove --prevent-downgrade /home/packages/bobs.db.tar.gz /home/packages/*.pkg.tar.zst'
      ExecStartPost=/usr/bin/logger Done - Local AUR Repo Update
      
      [Install]
      WantedBy=multi-user.target

Last modified: Fri Nov 28 02:15:37 2025